You are here: Dev Guide > Printing Receipt Data

Printing Receipt Data

If not already in place, add a reference to:Ncr.As.Interfaces.DeviceManagerInterfaces.dll

using Ncr.Managers.DeviceManager;

 

// ask the device manager for the printer interface by name

IPrinterDevice printer = deviceManager.GetDevice("Printer") as IPrinterDevice;

// or ask by device type

IPrinterDevice printer = deviceManager.GetDevice(typeof(IPrinterDevice)) as IPrinterDevice;

 

 

// instruct the printer that we are about to print at a particular station.

PrinterError error = printer.PrepareToPrint(PrinterStation.Receipt);

 

 

// feed receipt lines to the printer and handle errors.

List<string> receiptData = new List<string>();

// … build your receipt data

foreach( string receiptLine in receiptData )

{

    PrinterError error = printer.Write(receiptLine);

    if ( error != PrinterError.None )

    {

        // Handle the printer error.

    }

}

 

// Instruct the printer to finish the receiopt.

PrinterError error = printer. WaitForPrintingToComplete();

if ( error != PrinterError.None )

{

    // Handle the printer error.

}

 

The IPrinterDevice interface has numerous methods to assist in building lines of data that are passed to the printer’s Write method.  These methods include setting font attributes associated with the text, printing barcodes and graphics and performing 2 sided printing.  Please refer to the IPrinterDevice interface documentation for additional details.